//
//  SpreadCityCell.m
//  EnvironmentalProtection
//
//  Created by HCreater on 2018/12/24.
//  Copyright © 2018年 HCreater. All rights reserved.
//

#import "SpreadCityCell.h"

@interface SpreadCityCell ()

/// viewModle
@property (nonatomic, readwrite, strong) SpreadCityCellModel *viewModel;

/// IBOutlet
@property (weak, nonatomic) IBOutlet UILabel* cityLabel;
@property (weak, nonatomic) IBOutlet UILabel* endTimeLabel;
@property (weak, nonatomic) IBOutlet UIButton* xfBtn;

@end

@implementation SpreadCityCell

- (void)awakeFromNib
{
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}

#pragma mark - bind data
- (void)bindViewModel:(SpreadCityCellModel *)viewModel
{
    self.viewModel = viewModel;
    
    @weakify(self);
    
    self.cityLabel.text = viewModel.cityName;
    self.endTimeLabel.text = viewModel.endTime;
    
    [[RACObserve(self, layoutSubviews) takeUntil:[self rac_prepareForReuseSignal]] subscribeNext:^(id x)
    {
        @strongify(self);
        
        self.xfBtn.layer.cornerRadius = self.xfBtn.frame.size.height/2.0f;
        self.xfBtn.layer.borderColor = UIColorHex(#008f58).CGColor;
        self.xfBtn.layer.borderWidth = 1.0f;
    }];
    self.xfBtn.rac_command = self.viewModel.xfCommand;
}

@end

